package positioncysand.wk;

import positioncysand.wk.R;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.WindowManager;
import android.widget.TextView;
import positioncysand.wk.HTService;


public class PositionCYS extends Activity {
    /** Called when the activity is first created. */

	//public HTService objService=new HTService();
	Context cont;
    //////////////////////////////////////////////////////////////////////
	  @Override
	    public void onAttachedToWindow()
	    {  
	        this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
	        super.onAttachedToWindow();  
	    }
	  
	@Override
    public void onCreate(Bundle savedInstanceState) 
    {
    	//final Context cont = this;
        super.onCreate(savedInstanceState);
       
        
       // setContentView(R.layout.main);
         setContentView(R.layout.viewsender);
        
         SharedPreferences settings = getSharedPreferences("HT",MODE_PRIVATE);
         
         try
         {
         
		        if(!settings.contains("StartService"))			//FD PARA QUE PASE SIEMPRE POR LA PANTALLA  INICIAL.
		        {
		        	startActivity(new Intent(cont,HowToUseHt.class));
		        }        
		       
		        //
		        TextView txtImei = (TextView) findViewById(R.id.TextViewNuevoUsuario2);
		        TextView txtCode = (TextView) findViewById(R.id.TextViewCode2);
		        txtImei.setText(settings.getString("ImeiID",null));
		        txtCode.setText(txtCode.getText()+settings.getString("CodeActiv",null));
		        
		       	Log.i("PositionCYSActivity","[onCreate] Servicio comenzando...");
		        
		      	//startActivity(new Intent(cont,HTService.class));
		       	
		       	Intent myIntent = new Intent(cont, HTService.class);
		       	// objGPSData.updateCoordinates(objService.dbLat,objService.dbLon,objService.dbAlt,objService.flSpeed,objService.Imei,objService.strLevelbat);
		        //startService(myIntent);
		       	startActivity(myIntent);
		        
		        
		        
         }catch(Exception ex)
         {
        	 Log.e("PositionCYSActivity","[onCreate] ERROR EX: "+ex);
        	 Log.e("PositionCYSActivity","[onCreate] ERROR EX: "+ex.getLocalizedMessage());
        	 Log.e("PositionCYSActivity","[onCreate] ERROR EX: "+ex.getStackTrace());
        	 Log.e("PositionCYSActivity","[onCreate] ERROR EX: "+ex.getCause());
        	 Log.e("PositionCYSActivity","[onCreate] ERROR: "+ex.getMessage());
 
         }
        
    }    
    
	protected void onStop() {
		
		super.onStop();
	}
	
}